<h2>Search</h2>
<form method="post" action="<?=$html->url('/products/search');?>">
<input type="text" name="search"/>
<input type="submit"/>
</form>
<?php

if (isset($this->params['named']['view'])) {
	$userView = $this->params['named']['view'];
} else {
	$userView = 'default';
}

if ($userView == 'table') {
	$element = 'products/row';
	echo '<table>';
	echo $html->tableHeaders(array('Category', 'Name', 'Vendor', 'Price', 'Actions'));
} else {
	$element = 'product';
}


$quicklinks = array();

foreach($products as $product) {
  echo $this->renderElement($element, array('product'=>$product));
  if (!isset($quicklinks[$product['Member']['business_name']])) {
  	$quicklinks[$product['Member']['business_name']] = $html->link('About ' . $product['Member']['business_name'],array('controller' => 'producers', 'action' => 'about', $product['Member']['username']));
  }
}

ksort($quicklinks);
$this->set('quicklinks', $quicklinks);

if ($userView == 'table') {
	echo '</table>';
}
?>
<pre>
<?php //print_r($products); ?>
</pre>
<div style="clear:both"></div>
